package com.microframework.base.core.security.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import com.microframework.base.core.handler.GlobalExceptionHandler;
import com.microframework.base.core.security.aspect.SecurityAspect;
import com.microframework.base.core.security.properties.SecurityProperties;
import com.microframework.base.core.security.token.TokenParser;

/**
 * 安全自动配置类
 * 
 * 自动配置安全组件
 */
@Configuration
@ConditionalOnWebApplication
@EnableConfigurationProperties(SecurityProperties.class)
@ComponentScan(basePackages = "org.microframework.base.core.security")
@Import({ WebMvcSecurityConfig.class,GlobalExceptionHandler.class})
public class SecurityAutoConfiguration {
	
    /**
     * Token解析器
     */
    @Bean
    public TokenParser tokenParser() {
        return new TokenParser();
    }
    
    /**
     * 安全切面
     */
    @Bean
    public SecurityAspect securityAspect() {
        return new SecurityAspect();
    }
} 